<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        *{
            margin: 0;
            padding: 0;
        }
        ul,li{
            list-style: none;
        }
        #box{
            padding-top:20px;
            width: 301px;
            height: 553px;
            border: 1px solid #ff0000;
            margin: 100px auto;
            position: relative;
            
        }

        #box i img{
            
            width: 270px;
            height: 360px;
        }
        #box i{
            
            margin: auto;
            display: block;
            width: 270px;
            height: 360px;
        }
        #box .word1{
            margin-top: 8px;
            line-height: 12px;
            color: #6b6969;
            font-size: 12px;
            text-align: center;
        }
        #box .word2{
            margin-top: 10px;
            line-height: 15px;
            font-size: 15px;
            font-weight: 800;
            text-align: center;
        }
        #box .word3{
            overflow: hidden;
        }
        #box .word3 li{
            float: left;
            margin-top: 26px;
        }
        #box .word3 .l0{
            user-select: none;
            margin-left: 50px;
            color: #808080;
            font-size: 11px;
            line-height: 28px;
            margin-right: 10px;
        
        }
        #box .word3 #l1{
            user-select: none;
            width: 28px;
            height: 28px;
            color: #808080;
            line-height: 28px;
            border-left: 1px solid #e6e6e6;
            text-align: center;
            border-bottom: 1px solid #e6e6e6;
            border-top: 1px solid #e6e6e6;
        }
        #box .word3 #l2{
            user-select: none;
            width: 58px;
            height: 28px;
            line-height: 28px;
            border: 1px solid #e6e6e6;
            text-align: center;
          

        }
        #box .word3 #l3{
            user-select: none;
            width: 28px;
            height: 28px;
            line-height: 28px;
            border-right: 1px solid #e6e6e6;
            text-align: center;
            border-bottom: 1px solid #e6e6e6;
            border-top: 1px solid #e6e6e6;
            color: #808080;
        }
        .total{
            margin-left: 92px;
            margin-top: 25px;
        }
    </style>
</head>
<body>
    


  <div id="box">
        <i><img src="../images/2.jpg" alt=""></i>
        <p class="word1">纪梵希小羊皮口红</p>
        <p class="word2">￥<span id="price">340</span></p>
        <ul class="word3">
            <li class="l0">数量</li>
            <li id="l1">-</li>
            <li id="l2">0</li>
            <li id="l3">+</li>
        </ul>
        <p class="total">总价￥：<span id="total01">0</span></p>

        
   




  </div>

     <script>
    //    给l3添加点击事件
        l3.onclick = function(){
            // 点击+，l3 + 1
            l2.innerHTML++
            if(l2.innerHTML>0){
            // 计算总价
            total01.innerHTML = l2.innerHTML*1*price.innerHTML
            }
            
        }
        // 给l1添加点击事件
        l1.onclick = function(){
            // 限制l2.innerHTML>0
            if(l2.innerHTML>0){
                // 点击-l，l2.innerHTML - 1
            l2.innerHTML--
            // 计算总价
            total01.innerHTML = l2.innerHTML*1*price.innerHTML
            }
            
        }
     </script>
</body>
</html>